package com.huluobo.base.net

import com.huluobo.base.bean.CartBeanResult
import com.huluobo.base.bean.CategoryBeanResult
import com.huluobo.base.bean.CategoryGoodsListBeanResult
import com.huluobo.base.bean.CommentBean
import com.huluobo.base.bean.CommentBeanResult
import com.huluobo.base.bean.CommonBeanResult
import com.huluobo.base.bean.DetailBeanResult
import com.huluobo.base.bean.HomeBannerBeanResult
import com.huluobo.base.bean.HomeGoodsBeanResult
import com.huluobo.base.bean.HomeNavBean
import com.huluobo.base.bean.HomeNavBeanResult
import com.huluobo.base.bean.UserBeanResult
import io.reactivex.Observable
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Query

/**
 *  Created by LC on 2024/7/19.
 *  请求地址
 */
interface ApiService {
    @POST(Const.URL_LOGIN)
    fun login(@Body body: RequestBody): Observable<UserBeanResult>

    @POST(Const.URL_REGISTER)
    fun register(@Body body: RequestBody): Observable<UserBeanResult>

    @GET(Const.URL_HOME_BANNER)
    fun getHomeBanner(): Observable<HomeBannerBeanResult>

    @GET(Const.URL_HOME_GOODS_LIST)
    fun getHomeGoodsList(
        @Query(Const.PARAM_CATEGORY_ID) categoryId: Int,
        @Query(Const.PARAM_CURRENT_PAGE) currentPage: Int,
        @Query(Const.PARAM_PAGE_SIZE) pageSize: Int
    ): Observable<HomeGoodsBeanResult>

    @GET(Const.URL_HOME_NAV)
    fun getHomeNav(): Observable<HomeNavBeanResult>

    @GET(Const.URL_GOODS_DETAIL)
    fun getGoodsDetail(@Query(Const.PARAM_GOODS_ID) goodsId: Int): Observable<DetailBeanResult>

    @GET(Const.URL_COMMENT)
    fun getCommentList(@Query(Const.PARAM_COMMENT_ID) commentId: Int = 104): Observable<CommentBeanResult>

    @POST(Const.URL_ADD_TO_CART)
    fun addToCart(@Body body: RequestBody): Observable<CommonBeanResult>

    @GET(Const.URL_CART_LIST)
    fun getCartList(): Observable<CartBeanResult>

    @GET(Const.URL_CATEGORY_LIST)
    fun getCategoryList(): Observable<CategoryBeanResult>

    @GET(Const.URL_CATEGORY_GOODS)
    fun getCategoryGoodsList(
        @Query(Const.PARAM_CATEGORY_ID) categoryId: Int,
        @Query(Const.PARAM_CURRENT_PAGE) currentPage: Int,
        @Query(Const.PARAM_PAGE_SIZE) pageSize: Int
    ): Observable<CategoryGoodsListBeanResult>

    @POST(Const.URL_ADD_TO_CART)
    fun changeCartCount(@Body body: RequestBody): Observable<CommonBeanResult>

    @POST(Const.URL_DELETE_CART)
    fun deleteCart(@Body body: RequestBody): Observable<CommonBeanResult>

    @POST(Const.URL_UPDATE_ADDRESS)
    fun updateAddress(@Query(Const.PARAM_ADDRESS) address: String): Observable<CommonBeanResult>

    @POST(Const.URL_UPDATE_NICKNAME)
    fun updateNickname(@Query(Const.PARAM_NICKNAME) nickname: String): Observable<CommonBeanResult>

    @POST(Const.URL_UPDATE_SEX)
    fun updateSex(@Query(Const.PARAM_SEX) sex: String): Observable<CommonBeanResult>

    @POST(Const.URL_UPDATE_BIRTH)
    fun updateBirth(@Query(Const.PARAM_BIRTH) birth: String): Observable<CommonBeanResult>

    @Multipart
    @POST(Const.URL_UPDATE_ICON)
    fun updateIcon(@Part part: MultipartBody.Part): Observable<CommonBeanResult>
}